package com.ExcelServer.mapper;

import com.ExcelServer.pojo.entity.ExcelCreateInfo;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;

import org.apache.ibatis.annotations.*;

import java.util.List;
import java.util.Map;


/**
* @author admin
* @description 针对表【excel_create_info(保存excel -> mysql表的记录 )】的数据库操作Mapper
* @createDate 2023-12-27 10:57:48
* @Entity com.guet.teacherInfoManager.pojo.entity.ExcelCreateInfo
 * 动态sql，与mybatis配置文件相比更灵活
*/
@Mapper
public interface ExcelCreateInfoMapper extends BaseMapper<ExcelCreateInfo> {

    @Update("CREATE TABLE IF NOT EXISTS ${tableName} ("
            + "id INT AUTO_INCREMENT PRIMARY KEY, "
            + "${columnDefinition})")
    void createTable(@Param("columnDefinition") String columnDefinition,@Param("tableName")String tableName);

    @Insert("INSERT INTO ${tableName} ${line}")
    void insertToOtherTable(@Param("tableName")String tableName, @Param("line")String line);


    @Select("SELECT *  FROM ${tableName} where ${condition}")
    List<Map<String, Object>> getExcelInfoByTableName(String tableName, String condition);


    @Update("UPDATE ${tableName} set  ${line} where ${condition}" )
    boolean updateExcelInfoById(@Param("tableName")String tableName, @Param("line")String line,@Param("condition")String condition);


    @Delete("DELETE FROM ${tableName} where ${condition}")
    boolean deleteExcelInfoById(@Param("tableName") String tableName,@Param("condition") String condition);


    @Delete("drop table `${tableName}`")
    boolean deleteExcelByTableName(@Param("tableName") String tableName);

    Integer getLastId();
}
